//
//  CommentTableViewCell.m
//  A_Project_DLS151129_SQ
//
//  Created by 151129-49宋强 on 16/1/23.
//  Copyright © 2016年 www.lanou3g.com蓝鸥. All rights reserved.
//

#import "CommentTableViewCell.h"

@implementation CommentTableViewCell
- (void)dealloc
{
    [_headView release];
    [_nameLabel release];
    [_timtLabel release];
    [_contentLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.headView = [[UIImageView alloc] init];
        //_headView.backgroundColor = [UIColor redColor];
        _headView.layer.cornerRadius = 25;
        [self.contentView addSubview:_headView];
        [_headView release];
        self.nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont boldSystemFontOfSize:17];
       // _nameLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_nameLabel];
        [_nameLabel release];
        self.timtLabel = [[UILabel alloc] init];
        _timtLabel.font = [UIFont systemFontOfSize:15];
       // _timtLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_timtLabel];
        [_timtLabel release];
        self.contentLabel = [[UILabel alloc] init];
        _contentLabel.numberOfLines = 0;
      //  _contentLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_contentLabel];
        [_contentLabel release];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    _headView.frame = CGRectMake(10, 10, 50, 50);
    _nameLabel.frame = CGRectMake(_headView.frame.size.width + 10 + 2, 10, 200, 30);
    _timtLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.size.height + 10 + 5, 200, 15);
    CGFloat h = [[self class] heightWithtext:_contentLabel.text];
    _contentLabel.frame = CGRectMake(10, _headView.frame.size.width + 10 + 10, self.frame.size.width - 20, h);
}
+ (CGFloat)heightWithtext:(NSString *)text
{
    NSDictionary *dic = @{NSFontAttributeName: [UIFont systemFontOfSize:17]};
    CGSize s = CGSizeMake(355, 1000);
    CGRect r = [text boundingRectWithSize:s options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return r.size.height;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
